package com.eric.flowabledemo.service;

import com.eric.flowabledemo.constant.ResponseCodeEnum;
import com.eric.flowabledemo.constant.RmaStatusEnum;
import com.eric.flowabledemo.model.request.ProcessRequestData;
import com.eric.flowabledemo.model.response.ResponseResult;
import com.eric.flowabledemo.strategy.RmaProcessExecutor;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.UUID;

@Service
public class RmaProcessService {
    @Autowired
    private RuntimeService runtimeService;

    @Autowired
    private RmaProcessExecutor processExecutor;
    //开单
    public ResponseResult createRma(){
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("rma-common", UUID.randomUUID().toString());
        return new ResponseResult(ResponseCodeEnum.START_PROCESS, processInstance.getBusinessKey(), processInstance.getProcessInstanceId());
    }

    //下一步
    public ResponseResult nextStep(ProcessRequestData requestData){
        return processExecutor.complete(requestData);
    }

}
